package cn.hls.service.impl;

import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import cn.hls.dao.AreaDao;
import cn.hls.entity.Area;
import cn.hls.entity.vo.ExtTree;
import cn.hls.entity.vo.PageInfo;
import cn.hls.service.AreaService;
/**
 * @fileName: MoudleService.java
 * @Description: 区域Service接口
 * @author: yinghui.zhang
 * @email: uuhui@163.com
 * @date 2016年5月22日
 * @version V1.0
 */
@Service("areaService")
public class AreaServiceBean extends BaseServiceBean<Area> implements AreaService {
	@Resource(name="areaDao")
	private AreaDao dao;
	
	@Override
	public Area findArea(Area entity)throws Exception{
		return dao.findArea(entity);
	}
	
	@Override
	public String delete(Long id) throws Exception {
		return dao.delete(id);
	}
	
	@Override
	public PageInfo<Area> loadAreaInfo(PageInfo<Area> page, Area entity)
			throws Exception {
		return dao.loadAreaInfo(page, entity);
	}

	@Override
	public List<Area> loadAreaList(Area entity) throws Exception {
		return dao.loadAreaList(entity);
	}

	@Override
	public List<ExtTree> loadChildAreaInfo(Area entity, Object nodeId)
			throws Exception {
		return dao.loadChildAreaInfo(entity, nodeId);
	}

	@Override
	public boolean update(Area entity) throws Exception {
		Area tempArea=find(entity.getId());
		Date createTime=tempArea.getCreateTime();
		BeanUtils.copyProperties(entity, tempArea);
		tempArea.setCreateTime(createTime);
		tempArea.setUpdateTime(new Date());
		return super.update(tempArea);
	}
	
	@Override
	public void updateSort(String ids) throws Exception {
		dao.updateSort(ids);

	}
}
